<?php
/**
 * Field handler to provide race icons
 */
class mewdkp_handler_field_content_race extends views_handler_field {
	function render($values) {		
		$value = $values->{$this->field_alias};
		
		static $race = array();
		static $gender = array();
		if (empty($race)) {
			$race = variable_get('mewdkp_lookup_race', array());
		}
		if (empty($gender)) {
			$gender = variable_get('mewdkp_lookup_sex', array());
		}
		
		$race_key = $value;
		$player = node_load($values->nid);
		$gender_key = $player->field_mewdkp_sex[0]['value'];
		
		$path = 'http://' . $_SERVER['HTTP_HOST'] . '/' . drupal_get_path('module', 'mewdkp') . '/images/icons/r' . $race_key . '-' . $gender_key .'.png';
		
		return '<img class="mewdkp-race-icon-small" src="' . $path . '" title="' . $race[$value] .'" />';
	}
}